<!--
  * @Author: 汪军 624473119@qq.com
  * @Date: 2023-10-18 18:49:15
 * @LastEditors: 汪军 624473119@qq.com
 * @LastEditTime: 2023-12-12 08:58:18
  * @FilePath: \ekee-web\src\views\end\enterprise-center\EnterpriseCenter.vue
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 -->
<template lang="pug">
div.enterprise-center.relative.h100.overflow-y
  div(v-if="authorInfo.review_status == 1") 
    NotCertifiedYet(@change="goToVerify")
  div(v-else-if="authorInfo.review_status == 2") 
    div.reject
      div.tip-loading.f3 您提交的信息正在审核中，平台会在3个工作日内处理，请耐心等待。
      div.mt2.f4 审核状态：待审核
      div.mt2.f4 提交时间：{{ authorInfo.submit_time }}
    EnterpriseCertification(:isBtn="2")
  div.reject-container(v-else-if="authorInfo.review_status == 4") 
    div.reject
      div.tip-text.f4 审核状态：驳回
      div.tip-error.mt2.f4 提交时间：{{ authorInfo.submit_time }}
      div.tip-error.mt2.f4 审核时间：{{ authorInfo.review_time }}
      div.tip-text.flex.mt2.f4 
        div.reason-title 驳回理由：
        div.reason-text.tl {{ authorInfo.review_reason }}
    EnterpriseCertification(:isBtn="4" @confirm="onAgainAuthor")
  div.flex.column(v-else) 
    div.company.flex.justify-center.w100.tc 
      span.name {{ enterpriseInfo.company }}
      span.btn 已认证
    div.info.flex.justify-between
      div.item.flex.column(v-for="(item, index) in enterpriseInfoOther") 
        div.value {{ item.value }}
        div.name {{ item.name }}
</template>

<script setup>
import { ref, onMounted } from "vue";
import NotCertifiedYet from "@/views/end/enterprise-center/components/NotCertifiedYet.vue";
import EnterpriseCertification from "@/components/EnterpriseCertification.vue";
import enterpriseCenterApi from "@/api/enterprise-center";
import { CompanyInfo } from "@/api/login";
import { useRouter } from "vue-router";
import { getUserInfo } from "@/service";
const router = useRouter();

const enterpriseInfo = ref({
  company: "",
});
const userInfo = ref();
const authorInfo = ref({
  review_status: "",
  submit_time: "",
  review_time: "",
  review_reason: "",
}); // 认证状态：1=待支付(未认证)、2=待审核、3=通过、4=驳回
const enterpriseInfoOther = ref([
  {
    name: "易链值",
    value: "",
  },
  {
    name: "先易额度",
    value: "",
  },
  {
    name: "关注",
    value: "",
  },
  {
    name: "我的粉丝",
    value: "",
  },
]);

onMounted(() => {
  getAuthorInfo();
  getCompanyInfo();
});

// 获取认证信息回显
const getAuthorInfo = () => {
  enterpriseCenterApi.authorInfo().then((res) => {
    if (res.code) {
      authorInfo.value = res.data;
    }
  });
};

// 获取公司信息
const getCompanyInfo = () => {
  CompanyInfo().then((res) => {
    if (res.code == 1) {
      enterpriseInfo.value.company = res.data.name;
      enterpriseInfoOther.value = [
        {
          name: "易链值",
          value: res.data.chain_money,
        },
        {
          name: "先易额度",
          value: res.data.available_money,
        },
        {
          name: "关注",
          value: res.data.attention_quantity,
        },
        {
          name: "我的粉丝",
          value: res.data.fan_quantity,
        },
      ];
    }
  });
};

// 去认证
const goToVerify = () => {
  router.push("/go-to-verify?type=1&return_url=enterprise-center");
};

// 重新认证
const onAgainAuthor = () => {
  getAuthorInfo();
  getCompanyInfo();
};
</script>

<style lang="stylus" scoped>
.enterprise-center
  color: #888;
  .company
    padding: 30px 0px 14px 0px;
    border-bottom: 1px solid #E6E6E6;
    font-weight: bold;
    font-size: 24px;
    color: #000000;
    .btn
      margin-left: 12px;
      padding: 4px 10px;
      width: 62px;
      height: 28px;
      line-height: 28px;
      font-size: 14px;
      background: rgba(0,82,217,0.12);
      color: #2487E8;
      border-radius: 8px 8px 8px 8px;
      opacity: 1;
      border: 1px solid #2487E8;
  .info
    padding: 12px 16px;
    width: 100%;
    box-sizing: border-box;
    .item
      padding: 9px 0px;
      width: 224px;
      background: #2487E8;
      color: #FFFFFF;
      border-radius: 12px 12px 12px 12px;
      opacity: 1;
      .value
        font-size: 28px
      .name
        font-size: 20px
  .reject-container
    padding 16px 12px;
    border: 1px solid #E6E6E6;
  .reject
    margin: 16px 30px;
    padding: 16px;
    background: #F5F5F5;
    border-radius: 6px 6px 6px 6px;
    .tip-error
      color: #E84026;
    .tip-loading
      color: #18BC9F;
    .tip-color
      color: rgba(0,0,0,0.87);
    .reason-title 
      width: 70px;
    .reason-text
      width: 700px;
      word-wrap: break-word;
</style>
